#!/usr/bin/perl


################################################################
# Author   : DebugProject_Bourdin
# Created  : 06/06/2007
# Modified : 06/06/2007
# Script   : generate the html page that open comparison 
#	     in two different frames in the same window
################################################################

#check the command line
if(scalar(@ARGV) !=3){die "[way to use : <exec1Path> <exec2Path> <compare>]"}

$exec1Path = $ARGV[0];
$exec2Path = $ARGV[1];
$compare1 = $exec1Path.$ARGV[2];
$compare2 = $exec2Path.$ARGV[2];

#check that exec1Path exists
if(!(-d $exec1Path)){die "[directory <exec1Path> doesn't exist]"}

#check that exec2Path exists
if(!(-d $exec2Path)){die "[directory <exec2Path> doesn't exist]"}

#Openinning handles
open(RES1,">$compare1");
open(RES2,">$compare2");

#to create the file <compare> in exec1Path and exec2Path
#those files are used to show in two different frames in the same window, the results of the comparison

#write HTML instructions to do so, we particulary take care of writting the right path for out.xml
print RES1 "<HTML>\n\t
				<HEAD>\n\t\t
					<SCRIPT language=javascript>\n\t\t\t
						function aaa(){\n\t\t\t\t
							if(navigator.appName == \'Microsoft Internet Explorer\'){\n\t\t\t\t\t
								return(\'Vous ne pouvez pas sauvegarder cette page avec Internet Explorer, utiliser Mozilla Firefox.\');\n\t\t\t\t
							}\n\t\t\t\t
							else if(navigator.appName == \'Netscape\'){\n\t\t\t\t\t
								return(\'Avant de quitter, n\\'oubliez pas de sauvegarder cette page. Pour cela, faites Fichier/Enregistrer sous...\');\n\t\t\t\t
							}\n\t\t\t
						}\n\t\t
					</SCRIPT>\n\t
				</HEAD>\n\t
				<FRAMESET cols=\"50,50\" onmouseover=\"a=1\" onmouseout=\"a=0\" onmouseleave=\"a=0\" onbeforeunload=\"if(a==0) return(aaa());\">\n\t\t
					<FRAME name=\"fcomp1\" src=\"".$exec1Path."out.xml\" scrolling=\"auto\">\n\t\t
					<FRAME name=\"fcomp2\" src=\"".$exec2Path."out.xml\" scrolling=\"auto\">\n\t
				</FRAMESET>\n
			</HTML>";

print RES2 "<HTML>\n\t
				<HEAD>\n\t\t
					<SCRIPT language=javascript>\n\t\t\t
						function aaa(){\n\t\t\t\t
							if(navigator.appName == \'Microsoft Internet Explorer\'){\n\t\t\t\t\t
								return(\'Vous ne pouvez pas sauvegarder cette page avec Internet Explorer, utiliser Mozilla Firefox.\');\n\t\t\t\t
							}\n\t\t\t\t
							else if(navigator.appName == \'Netscape\'){\n\t\t\t\t\t
								return(\'Avant de quitter, n\\'oubliez pas de sauvegarder cette page. Pour cela, faites Fichier/Enregistrer sous...\');\n\t\t\t\t
							}\n\t\t\t
						}\n\t\t
					</SCRIPT>\n\t
				</HEAD>\n\t
				<FRAMESET cols=\"50,50\" onmouseover=\"a=1\" onmouseout=\"a=0\" onmouseleave=\"a=0\" onbeforeunload=\"if(a==0) return(aaa());\">\n\t\t
					<FRAME name=\"fcomp1\" src=\"".$exec1Path."out.xml\" scrolling=\"auto\">\n\t\t
					<FRAME name=\"fcomp2\" src=\"".$exec2Path."out.xml\" scrolling=\"auto\">\n\t
				</FRAMESET>\n
			</HTML>";

#Closing handles 		
close RES1;
close RES2;
